//
//  HomeViewController.m
//  WeicoShow
//
//  Created by shawn on 16/1/17.
//  Copyright © 2016年 shawn. All rights reserved.
//

#import "HomeViewController.h"
#import "WeiboSDK.h"
#import "WeiboService.h"
#import "Common.h"
#import "AppDelegate.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    ((AppDelegate *)[UIApplication sharedApplication].delegate).wbdelegate = self;
    if ([WeiboService isAuthorized]) {
        NSLog(@"has loged");
    } else {
        NSLog(@"not log");
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)logon:(id)sender {
    WBAuthorizeRequest *request = [WBAuthorizeRequest request];
    request.redirectURI = kRedirectURI;
    request.scope = @"all";
    request.userInfo = @{@"SSO_From": @"SendMessageToWeiboViewController",
                         @"Other_Info_1": [NSNumber numberWithInt:123],
                         @"Other_Info_2": @[@"obj1", @"obj2"],
                         @"Other_Info_3": @{@"key1": @"obj1", @"key2": @"obj2"}};
    [WeiboSDK sendRequest:request];
}

#pragma  mark forCallBackDidReceiveWeiboResponseDelegate
//登录完成获取token后回调此方法刷新界面
- (void)CallBackDidReceiveWeiboResponse:(id)obj {
    NSLog(@"into CallBack method");
    [self performSegueWithIdentifier:@"toHomeTableView" sender:nil];
}
@end
